package com.bjpowernode.boss.mvc.models;

import com.bjpowernode.boss.common.enums.ResponseCode;
import lombok.Data;

import java.util.Arrays;

/**
 * @author yu
 * @date 2024/7/7  18:01
 */

@Data
public class AjaxResult {
    private Integer code ;
    private String msg ;
    private Object data ;

    public static AjaxResult OK(Object data) {
        AjaxResult ajaxResult = new AjaxResult() ;

        ajaxResult.setCode(ResponseCode.OK.getNumber());
        ajaxResult.setMsg(ResponseCode.OK.getMsg());
        ajaxResult.setData(data);

        return ajaxResult ;
    }

    public static AjaxResult OK() {
        AjaxResult ajaxResult = new AjaxResult() ;

        ajaxResult.setCode(ResponseCode.OK.getNumber());
        ajaxResult.setMsg(ResponseCode.OK.getMsg());
        ajaxResult.setData("");

        return ajaxResult ;
    }

    public static AjaxResult FAIL(ResponseCode responseCode) {
        AjaxResult ajaxResult = new AjaxResult() ;

        ajaxResult.setCode(responseCode.getNumber());
        ajaxResult.setMsg(responseCode.getMsg());
        ajaxResult.setData("");

        return ajaxResult ;
    }

    public static AjaxResult FAIL() {
        AjaxResult ajaxResult = new AjaxResult() ;

        ajaxResult.setCode(ResponseCode.FAIL.getNumber());
        ajaxResult.setMsg(ResponseCode.FAIL.getMsg());
        ajaxResult.setData("");

        return ajaxResult ;
    }
}
